package com.project.web;

import com.project.pojo.Library;
import com.project.service.LibraryService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "SelectByIdServlet", value = "/SelectByIdServlet")
public class SelectByIdServlet extends HttpServlet {
    private LibraryService Service = new LibraryService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");

        Library library = Service.selectById(Integer.parseInt(id));

        request.setAttribute("library",library);

        request.getRequestDispatcher("/update.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
